home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -in_the_mag- / reader_requests / mpmorph4x / source / sd / agdoc2html.rexx < prev    next >
OS/2 REXX Batch file  |  1999-12-01  |  3KB  |  118 lines

  1. /* Rexx program to convert makedoc guides to html
  2.  *
  3.  * No error checking!
  4.  *
  5.  * Relies on very specific format!
  6.  *
  7.  * $VER: AGDoc2HTML.rexx 1.0 (16.3.97)
  8.  */
  9.  
  10. parse arg arg1
  11.  
  12. seealso = 0
  13. call open('in',arg1,'r')
  14. line = readln('in')
  15. do while ~eof('in')
  16.     word1 = word(line,1)
  17.     if word1 = "@database" then do
  18.     end
  19.     else if word1 = "@rem" then do
  20.     end
  21.     else if word1 = "@node" then do
  22.         name = word(line,2)
  23.         if name ~= "main" then do
  24.             name = substr(name,2,length(name)-2)
  25.             title = arg1"/"name
  26.         end
  27.         else do
  28.             title = arg1
  29.         end
  30.         call WriteHeaders(name" "title)
  31.         seealso = 0
  32.     end
  33.     else if substr(line,1,2) = "@{" then do
  34.         call writech('out','<A HREF="')
  35.         index1 = index(line,"link")
  36.         index2 = index(line,"}")
  37.         len = length(line)
  38.         link = substr(line,index1+6,len-index1-7)
  39.         call writeln('out',link'.html">'link'</A>')
  40.     end
  41.     else if word1 = "@endnode" then do
  42.         call WriteTrailers
  43.     end
  44.     else do
  45.         if seealso then do
  46.             newline = ""
  47.             inlink = 0
  48.             link = ""
  49.             do i=1 to length(line) by 1
  50.                 c = substr(line,i,1)
  51.                 if inlink then do
  52.                     if (c = " ") | (c = ",") | (c = ".") then do
  53.                         if (index(link,"()") ~= 0) & (index(link,"/") = 0) then do
  54.                             newline = newline||'<A HREF="'substr(link,1,length(link)-2)'.html">'link'</A>'
  55.                             newline = newline||c
  56.                         end
  57.                         else do
  58.                             newline = newline||link||c
  59.                         end
  60.                         inlink = 0
  61.                         link = ""
  62.                     end
  63.                     else do
  64.                         link = link||c
  65.                     end
  66.                 end
  67.                 else do
  68.                     if (c = " ") | (c = ",") | (c = ".") then do
  69.                         newline = newline||c
  70.                     end
  71.                     else do
  72.                         link = c
  73.                         inlink = 1
  74.                     end
  75.                 end
  76.             end
  77.             if inlink then do
  78.                 if (index(link,"()") ~= 0) & (index(link,"/") = 0) then do
  79.                     newline = newline||'<A HREF="'substr(link,1,length(link)-2)'.html">'link'</A>'
  80.                 end
  81.                 else do
  82.                     newline = newline||link||c
  83.                 end
  84.             end
  85.             call writeln('out',newline)
  86.         end
  87.         else do
  88.             call writeln('out',line)
  89.             if index(line,"SEE ALSO") ~= 0 then do
  90.                 seealso = 1
  91.             end
  92.         end
  93.     end
  94.     line = readln('in')
  95. end
  96. call close('in')
  97. return
  98.  
  99. WriteHeaders: procedure
  100.     parse arg name title
  101.     say name
  102.     call open('out',name".html",'w')
  103.     call writeln('out',"<HTML>")
  104.     call writeln('out',"<HEAD>")
  105.     call writeln('out',"<TITLE>"title"</TITLE>")
  106.     call writeln('out',"</HEAD>")
  107.     call writeln('out',"<BODY>")
  108.     call writeln('out',"<H1>"title"</H1><P>")
  109.     call writeln('out',"<PRE>")
  110.     return
  111.  
  112. WriteTrailers: procedure
  113.     call writeln('out',"</PRE>")
  114.     call writeln('out',"</BODY>")
  115.     call writeln('out',"</HTML>")
  116.     call close('out')
  117.     return
  118.